package com.fr.chart.core;

import com.fr.base.core.json.JSONException;
import com.fr.base.core.json.JSONObject;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.chart.LineStyleInfo;
import com.fr.chart.base.equals.Equals;
import com.fr.chart.core.glyph.SoloGlyph;
import com.fr.report.io.xml.ReportXMLUtils;
import java.awt.Graphics;
import java.awt.Shape;
import java.awt.geom.GeneralPath;

public class FoldLine extends SoloGlyph
{
  private static final long serialVersionUID = -1373367876731556523L;
  public static final String XML_TAG = "FoldLine";
  private GeneralPath generalPath;
  private LineStyleInfo lineStyleInfo = new LineStyleInfo();

  public FoldLine()
  {
  }

  public FoldLine(GeneralPath paramGeneralPath)
  {
    setGeneralPath(paramGeneralPath);
  }

  public void draw(Graphics paramGraphics)
  {
    this.lineStyleInfo.paint(paramGraphics, getGeneralPath());
  }

  public Shape getShape()
  {
    return getGeneralPath();
  }

  public void setGeneralPath(GeneralPath paramGeneralPath)
  {
    this.generalPath = paramGeneralPath;
  }

  public GeneralPath getGeneralPath()
  {
    return this.generalPath;
  }

  public void setLineStyleInfo(LineStyleInfo paramLineStyleInfo)
  {
    this.lineStyleInfo = paramLineStyleInfo;
  }

  public LineStyleInfo getLineStyleInfo()
  {
    return this.lineStyleInfo;
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if (paramXMLableReader.isChildNode())
    {
      String str = paramXMLableReader.getTagName();
      if (str.equals("GeneralPath"))
        setGeneralPath(ReportXMLUtils.readGeneralPath(paramXMLableReader));
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    paramXMLPrintWriter.startTAG("FoldLine");
    if (getGeneralPath() != null)
      ReportXMLUtils.writeGeneralPath(paramXMLPrintWriter, getGeneralPath());
    paramXMLPrintWriter.end();
  }

  public boolean equals(Object paramObject)
  {
    if (!(paramObject instanceof FoldLine))
      return false;
    FoldLine localFoldLine = (FoldLine)paramObject;
    if (!(Equals.euqalsShape(getGeneralPath(), localFoldLine.getGeneralPath())))
      return false;
    return (Equals.equals(localFoldLine.lineStyleInfo, this.lineStyleInfo));
  }

  public JSONObject toJSONObject()
    throws JSONException
  {
    JSONObject localJSONObject = super.toJSONObject();
    if (this.generalPath != null)
      localJSONObject.put("generalPath", this.generalPath);
    if (this.lineStyleInfo != null)
      localJSONObject.put("lineStyleInfo", this.lineStyleInfo.toJSONObject());
    return localJSONObject;
  }
}